package com.example.myspringboot.caffeine.testDemo;

import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;
import com.example.myspringboot.domain.ImChatUserGroupMessage;
import com.example.myspringboot.mapper.ImChatUserGroupMessageMapper;
import com.example.myspringboot.service.ImChatUserGroupMessageService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class CaffeineService {

    private final static Logger log = LoggerFactory.getLogger(CaffeineService.class);

    @Autowired
    private ImChatUserGroupMessageService imChatUserGroupMessageService;

//    @Cacheable(value = "IZUUL", key = "#userId.concat(#couponId)")
    @Cacheable("IZUUL")
    public List<ImChatUserGroupMessage> getFullReductionList(String[] id) {
        LambdaQueryChainWrapper<ImChatUserGroupMessage> lambdaQuery = imChatUserGroupMessageService.lambdaQuery();
        try {
            Thread.sleep(10000);
        }catch (Exception e) {
            e.getMessage();
        }
        List<ImChatUserGroupMessage> list = lambdaQuery.in(ImChatUserGroupMessage::getId, id).list();
        log.info("*************" + id);
        return list;
    }
}
